﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Threading;
using System.Globalization;
using Nivdal.AuxCode;

namespace Nivdal
{
    public partial class Search : System.Web.UI.Page
    {

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!HttpContext.Current.User.Identity.IsAuthenticated)
                Response.Redirect("Default.aspx");
            this.Title = Resources.Resource.Default_PageTitle + ", " + Resources.Resource.Search_PageTitle;
            PageNameLabel.Text = Resources.Resource.Search_PageTitle;
            PageNameLabel2.Text = Resources.Resource.Search_PageTitle;

            //OnlineUser ou = (OnlineUser)Session["User"];

            //if (ou.TeamId == "Null")
            //    Response.Redirect("~/GeneralMessage.aspx?MessageString=M74ggdizz5wfeh");         


        }

        protected override void InitializeCulture()
        {
            if (HttpContext.Current.User.Identity.IsAuthenticated)
            {

                OnlineUser ou = (OnlineUser)Session["User"];
                Thread.CurrentThread.CurrentUICulture = new CultureInfo(ou.UICulture);
                Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(ou.Culture);
            }
        }

        protected void SearchButtonClick(object sender, EventArgs e)
        {
            string SearchString = this.SearchTextBox.Text.Trim();

            decimal SearchId;
            long TempInt;
            bool IsDecimal = Decimal.TryParse(SearchString, out SearchId);
            bool IsInt = long.TryParse(SearchString, out TempInt);

            this.SearchSqlDataSource.SelectParameters.Clear();
            this.SearchSqlDataSource.SelectParameters.Add("SearchString", SearchString);
            this.SearchSqlDataSource.SelectParameters.Add("SearchType", this.SearchTypeDDL.SelectedValue);
            if (IsDecimal && IsInt)
                this.SearchSqlDataSource.SelectParameters.Add("SearchId", SearchString);

            if (!ResultsPanel.Visible)
                this.ResultsPanel.Visible = true;
            this.ResultsPanel.Update();
        }

  

    }
}